package com.xingbang.uitl.configread;
import com.xingbang.uitl.constant.ConstantNum;
import com.xingbang.uitl.constant.ConstantStr;

import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
 * @author zchcpy
 * @date 2019/1/12 11:09
 * dataclean.cn.xb.zutils.configread
 */
public class ConfigUtils {
	//private Logger mylog = LoggerFactory.getLogger(ConfigUtils.class);
	/**
	 * 是否终止程序
	 */
	public boolean termination() {
		// #是否终止程序 0 终止 1 继续
		int stop = ConfigSettingsUtil.getInstance("application.properties").getInteger("stopclean", ConstantNum.Z0);
		return stop == 0;
	}
	/**
	 * 获取保留截止日期
	 */
	public String getCleanOffset(int cid) {
		Calendar calendar = Calendar.getInstance();
		int dataKeepMonth = ConfigSettingsUtil.getInstance("application.properties").getInteger(String.valueOf(cid), ConstantNum.N7);
		calendar.add(Calendar.MONTH, dataKeepMonth);
		return new SimpleDateFormat(ConstantStr.YYYY_MM_DD_END_OF_MONTH).format(calendar.getTime());
	}
	//	/**
	//	 * 查询数据库公司信息
	//	 */
	//	public boolean getCompanyInfo(Integer cid, DaoCompany daoCompany) {
	//		return null == daoCompany.findOne(cid);
	//	}
}